//
//  XQCourseVideoCommentTableViewCell.swift
//  XiaoQiQiaoSwift
//
//  Created by tech-lab on 2016/12/2.
//  Copyright © 2016年 校企桥. All rights reserved.
//

import UIKit

class XQCourseVideoCommentTableViewCell: UITableViewCell {
    var icon = UIImageView()
    var nameLabel = UILabel()
    var timeLabel = UILabel()
    var sortLabel = UILabel()
    var contentLabel = UILabel()
    var reportButton = UIButton()
    var replyButton = UIButton()

    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        InitUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var commentMode:XQCourseVideoCommentMianMode?{
        didSet{
            let url = URL.init(string: (commentMode?.avatar)!)
            icon.kf.setImage(with: url)
  
            nameLabel.text = commentMode?.nick_name
            timeLabel.text = commentMode?.c_time
            contentLabel.text = commentMode?.content
            
        }
    }
    
    
    func InitUI(){
        
        icon = UIImageView.init(frame: CGRect.zero)
        self.contentView .addSubview(icon)
        
        nameLabel = UILabel.init(frame: CGRect.zero)
        self.contentView .addSubview(nameLabel)
        
        sortLabel = UILabel.init(frame: CGRect.zero)
        sortLabel.font = UIFont.systemFont(ofSize: 12)
        sortLabel.textColor = UIColor.lightGray
        self.contentView .addSubview(sortLabel)

        timeLabel = UILabel.init(frame: CGRect.zero)
        timeLabel.font = UIFont.systemFont(ofSize: 12)
        timeLabel.textColor = UIColor.lightGray
        self.contentView .addSubview(timeLabel)

        contentLabel = UILabel.init(frame: CGRect.zero)
        contentLabel.font = UIFont.systemFont(ofSize: 12)
        self.contentView .addSubview(contentLabel)
        contentLabel.numberOfLines = 0
        
        reportButton = UIButton.init(frame: CGRect.zero)
        reportButton.setTitle("举报", for: .normal)
        reportButton.setTitleColor(UIColor.blue, for: .normal)
        reportButton.titleLabel?.font = UIFont.systemFont(ofSize: 13)
        self.contentView.addSubview(reportButton)
        
        replyButton = UIButton.init(frame: CGRect.zero)
        replyButton.setTitle("回复", for: .normal)
        replyButton.setTitleColor(UIColor.blue, for: .normal)
        replyButton.titleLabel?.font = UIFont.systemFont(ofSize: 13)
        self.contentView.addSubview(replyButton)

        icon.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView.snp.left).offset(10)
            make.top.equalTo(self.contentView.snp.top).offset(10)
            make.width.equalTo(40)
            make.height.equalTo(40)
        }
        
        sortLabel.snp.makeConstraints { (make) in
            make.right.equalTo(self.contentView.snp.right).offset(-10)
            make.top.equalTo(self.contentView.snp.top).offset(10)
        }
        
        nameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(icon.snp.right).offset(5)
            make.bottom.equalTo(icon.snp.centerY)
        }
        
        timeLabel.snp.makeConstraints { (make) in
            make.top.equalTo(icon.snp.centerY)
            make.left.equalTo(icon.snp.right).offset(5)
        }
    
        contentLabel.snp.makeConstraints { (make) in
            make.right.equalTo(self.contentView.snp.right).offset(-10)
            make.left.equalTo(self.contentView.snp.left).offset(10)
            make.top.equalTo(icon.snp.bottom).offset(5)
            
        }
        
        reportButton.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView.snp.left).offset(15)
            make.top.equalTo(contentLabel.snp.bottom).offset(5)
        }
        
        replyButton.snp.makeConstraints { (make) in
            make.right.equalTo(self.contentView.snp.right).offset(-10)
            make.top.equalTo(contentLabel.snp.bottom).offset(5)
        }

    }

    
    

}
